{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加自定义属性</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" name="add_article" id="add_article" enctype="multipart/form-data">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">名称：</label>
                            <div class="input-group col-sm-4">
                                <input id="jia_name" name="jia_name" type="text" class="form-control jia_name">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">属性：</label>
                            <div class="input-group col-sm-4">
                                <input id="jia_value" name="jia_value" type="text" class="form-control jia_value">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-3">
                                <button class="btn btn-primary btsave"  type="button"><i class="fa fa-save"></i> 保存</button>&nbsp;&nbsp;&nbsp;
                                <a class="btn btn-danger" href="javascript:history.go(-1);"><i class="fa fa-close"></i> 返回</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

        </div>
    </div>
</div>
{include file="public/footer" /}

<script>
    $(".btsave").on('click',function () {
        $('.btn').attr('disabled',true);
        var jia_name = $(".jia_name").val();
        var jia_value = $(".jia_value").val();
        if(jia_name==''){
            layer.msg("名称不能为空", {icon: 1, time: 1500, shade: 0.1}, function (index) {
            });
            $('.btn').removeAttr('disabled');
            return false;
        }
        if(jia_value==''){
            layer.msg("属性不能为空", {icon: 1, time: 1500, shade: 0.1}, function (index) {
            });
            $('.btn').removeAttr('disabled');
            return false;
        }
        $.ajax({
            url: "{:url('Building/addCostun')}",
            type: "post",
            dataType:'json',
            data: $("#add_article").serialize(),
            success: function (data) {
                if (data.code == 200) {
                    wk.success(data.msg,"{:url('Building/costun')}",1);
                } else if(data.code == 100){
                    $('.btn').removeAttr('disabled');
                    wk.error(data.msg,'',2);
                    return false;
                }
            }
        });
    })
</script>
</body>
</html>